<template>
  <div class="game-events" v-if="showEvent">
    <div class="event-card">
      <div class="event-header">{{ currentEvent.title }}</div>
      <div class="event-content">
        <p>{{ currentEvent.description }}</p>
        <div class="event-actions">
          <button 
            v-for="(action, index) in currentEvent.actions" 
            :key="index" 
            @click="handleAction(action)"
            class="event-button"
          >
            {{ action.text }}
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'GameEvents',
  props: {
    showEvent: {
      type: Boolean,
      default: false
    },
    currentEvent: {
      type: Object,
      default: () => ({
        title: '事件',
        description: '这是一个游戏事件',
        actions: [
          { text: '确定', action: 'confirm' }
        ]
      })
    }
  },
  methods: {
    handleAction(action) {
      this.$emit('action', action);
    }
  }
}
</script>

<style scoped>
.game-events {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.event-card {
  background-color: white;
  border-radius: 12px;
  width: 80%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.event-header {
  background-color: #ff9800;
  color: white;
  padding: 15px;
  font-weight: bold;
  font-size: 18px;
  text-align: center;
}

.event-content {
  padding: 20px;
}

.event-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.event-button {
  background-color: #4CAF50;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.3s;
}

.event-button:hover {
  background-color: #388E3C;
}
</style>